package com.wit.util;

public class BaseBackUp {
	private String username;
	private String password;
	private String database;
	private String baseIP;
	private String filePath;
	private String mysqlPath;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getDatabase() {
		return database;
	}
	public void setDatabase(String database) {
		this.database = database;
	}
	public String getBaseIP() {
		return baseIP;
	}
	public void setBaseIP(String baseIP) {
		this.baseIP = baseIP;
	}
	public String getFilePath() {
		return filePath;
	}
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	public String getMysqlPath() {
		return mysqlPath;
	}
	public void setMysqlPath(String mysqlPath) {
		this.mysqlPath = mysqlPath;
	}
	
	 public boolean backup_run(){
		 String stmt=null;
		 stmt=mysqlPath+" "+database+" -h "+baseIP+" -u"+username+" -p"+password
                +" utf8"+" --result-file="+filePath;
	       System.out.println(stmt); 
	        try{
	            Runtime.getRuntime().exec(stmt);
	            return true;
	        }catch(Exception e){
	            e.printStackTrace();
	            return false;
	        }
	    }
	 public static void main(String[] argv)
	 {
		 BaseBackUp bb=new BaseBackUp();
		 bb.setBaseIP("localhost");
		 bb.setDatabase("wit");
		 bb.setFilePath("E:\\asdf.sql");
		bb.setPassword("ever");
		bb.setUsername("root");
		bb.backup_run();
	 }


}
